<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <style type="text/css">
        .div1{
            width: 100px;
            height: 100px;
            background: red;
            margin-top: 20px;
        }
        button{
            padding: 10px 25px;
            border: none;
            background-color: green;
            color: #fff;
            border-radius: 5px;
        }
    </style>
    <title>Vue示例代码7</title>
</head>
<body>
    <div id="app">
        <button v-on:click="fn">toggle</button>
        <div class="div1" v-show="bol"></div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script type="text/javascript">
        var vm=new Vue({
            el: '#app',
            data:{
                bol:false
            },
            methods:{
                fn:function () {
                    this.bol=!this.bol
                }
            }
        });
    </script>
</body>
</html>